<!DOCTYPE html>
<!-- <html lang="zh-cn"> -->
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>obj</title>
	</head>
	<script src="./three.js/build/three.js"></script>
	<!-- <script src="./three_r102/examlpes/js/loaders/ObjectLoader2.js"></script> -->
	<script type="text/javascript" src="./three.js/examples/js/loaders/OBJLoader.js"></script>
	<body>
		<script>
			var scene =new THREE.Scene();
			var loader=new THREE.OBJLoader();
			loader.load( "./geo/n.obj", function ( obj ) {
				console.log(obj);
			  var geometry = obj.children[ 0 ].geometry;
			  geometry.attributes.uv2 = geometry.attributes.uv;
			  geometry.center();
			  // obj.center();
			  var material = new THREE.MeshLambertMaterial({color:0x0000ff}); 
			  var mesh = new THREE.Mesh( geometry, material );
			  mesh.scale.multiplyScalar(100);
			   
			  scene.add( mesh );
			  } );
			//创建网格模型
			var geometry = new THREE.BoxGeometry(100,100,100); //创建几何体
			var material = new THREE.MeshLambertMaterial({color:0x0000ff}); //创建材质
			var mesh = new THREE.Mesh(geometry,material);//网格模型对象生成Mesh
			scene.add(mesh);  
			  
			  
			//灯光
			var point =new THREE.PointLight(0xffffff);
			point.position.set(400,200,300); 
			scene.add(point);
			
			//环境光
			var ambient = new THREE.AmbientLight(0x444444);
			scene.add(ambient);
			
			//相机设置
			var width =window.innerWidth; //窗口宽度
			var height = window.innerHeight; //窗口高度
			var k =width/height; //窗口宽高比
			var s =2000; //三维场景显示范围控制系数，系数越大，显示范围越大
			
			//创建相机
			var camera =new THREE.OrthographicCamera(-s*k,s*k,s,-s,1,1000);
			camera.position.set(100,100,50);
			camera.lookAt(scene.position);//指向场景对象
			
			//创建渲染器
			var renderer= new THREE.WebGLRenderer() ;
			renderer.setSize(width,height);
			renderer.setClearColor(0xb9d3ff,1);
			document.body.appendChild(renderer.domElement); //body元素中插入canvas对象。
			  
			renderer.render(scene,camera);
		</script>
	</body>
</html>
